<?php
$this->breadcrumbs = array(
	'凭证统计报表' => array(
		'stat'
	),
	'单科统计'
);

?>

<h1>单科统计</h1>
<div class="form">
<?php $form = $this
	->beginWidget('CActiveForm',
		array(
			'action' => Yii::app()->createUrl($this->route),
			'method' => 'get',
		));
?>

<fieldset>
<legend>搜索条件</legend>

	<?php echo $form->errorSummary($statModel); ?>
	<?php if(!AccessControl::isAltMode()){ ?>
	<div class="row">
		<?php echo $form->labelEx($statModel, 'projectId'); ?>
		<?php echo $form
			->dropDownList($statModel, 'projectId',
				CHtml::listData(AccountTokenProject::getAll(), 'id', 'name'),
				array(
					'empty' => '所有公司账目'
				));
		?>
		<?php echo $form->error($statModel, 'projectId'); ?>
	</div>
	<?php } ?>
	<div class="row">
		<?php echo $form->label($statModel, 'tokenDateStart'); ?>
		<?php $this
			->widget('zii.widgets.jui.CJuiDatePicker',
				array(
					'model' => $statModel,
					'attribute' => 'tokenDateStart',
				));
		?> - 
		<?php $this
			->widget('zii.widgets.jui.CJuiDatePicker',
				array(
					'model' => $statModel,
					'attribute' => 'tokenDateEnd',
				));
		?>
	</div>
	<div class="row">
		<?php echo $form->labelEx($statModel, 'categoryId'); ?>
		<?php echo $this
			->widget("widgets.accountTokenCategory.JAccountTokenCategorySelector",
				array(
					"model" => $statModel,
					"attribute" => "categoryId",
				), true);
		?>
		<?php echo $form->error($statModel, 'categoryId'); ?>
	</div>
	<div class="row buttons">
		<?php echo CHtml::submitButton('确定'); ?>
	</div>

</fieldset>
<?php $this->endWidget(); ?>
</div>
<?php
if ($statModel->validate()) {
?>
<?php $this
		->widget('zii.widgets.grid.CGridView',
			array(
				'id' => 'account-token-single-category-grid',
				'dataProvider' => new CArrayDataProvider($statModel->findItems(),
					array(
						'pagination' => false
					)),
				//'rowCssClassExpression' => '$data->isBalanced()?($row%2?"odd":"even"):"account-token-unbalanced"',
				'columns' => array(
					//'id',
					array(
						'header' => '账本',
						'name' => 'token.project.name',
					),
					array(
						'header' => '科目',
						'name' => 'category.displayLongName',
					),
					array(
						'header' => '日期',
						'name' => 'token.tokenDate',
					),
					array(
						'header' => '凭证号',
						'name' => 'token.number',
					),
					array(
						'header' => '摘要',
						'name' => 'summary',
						'type' => 'raw',
						'value' => 'CHtml::link($data->summary,array("view","id"=>$data->tokenId),array("target"=>"_blank"))',
						'footer' => '总量',
					),
					array(
						'header' => '借',
						'type' => 'currency',
						'name' => 'debit',
						'footer' => Yii::app()->format->formatCurrency($overallStat['totalDebit']),
					),
					array(
						'header' => '贷',
						'type' => 'currency',
						'name' => 'credit',
						'footer' => Yii::app()->format->formatCurrency($overallStat['totalCredit']),
					),
				),
			));
?>

<?php

}
?>
